<?php

namespace Callback;

use C\L\AdmController;
use C\L\Logs;

class TencentController extends AdmController
{

    protected function init()
    {
        $this->logger = (new Logs)->set('tencent_' . date('Ymd') . '.log');
    }

    public function indexAction()
    {
        $this->logger->notice(json_encode($_GET));

        $params = [
            'channel'    => $this->request->getQuery('channel', 'string', null) ?? 'tencent',
            'imei'       => strtolower($this->request->getQuery('muid', 'string', null)),
            'oaid'       => strtolower($this->request->getQuery('oaid', 'string', null)),
            'other_info' => json_encode($_GET),
        ];

        try {
            $this->s_channel->record($params);

            $this->logger->notice('success');
        } catch (\Exception $error) {
            $this->logger->notice('failure: ' . $error->getMessage());
        }
    }
}
